package com.work.music.controller;

import com.work.music.common.ResponseJson;
import com.work.music.exception.AjaxOperationFailException;
import com.work.music.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/app/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;

    /**
     * 获取验证码
     * @return
     */
    @RequestMapping("/getPhoneCode")
    @ResponseBody
    public ResponseJson getPhoneCode() throws AjaxOperationFailException {
        return userService.getPhoneCode();
    }

    /**
     * 注册
     * @return
     * @throws AjaxOperationFailException
     */
    @RequestMapping("/register")
    @ResponseBody
    public ResponseJson register() throws AjaxOperationFailException{
        return userService.register();
    }

    /**
     * 忘记密码
     * @return
     * @throws AjaxOperationFailException
     */
    @RequestMapping("/forgetPwd")
    @ResponseBody
    public ResponseJson forgetPwd() throws AjaxOperationFailException {
        return userService.forgetPwd();
    }

    /**
     * 登陆
     * @return
     * @throws AjaxOperationFailException
     */
    @RequestMapping("/login")
    @ResponseBody
    public ResponseJson login() throws AjaxOperationFailException{
        return userService.login();
    }

    /**
     * 获取用户个人资料
     * @return
     * @throws AjaxOperationFailException
     */
    @RequestMapping("/getUserInfo")
    @ResponseBody
    public ResponseJson getUserInfo() throws AjaxOperationFailException {
        return userService.getUserInfo();
    }

    /**
     * 修改用户个人资料
     * @return
     * @throws AjaxOperationFailException
     */
    @RequestMapping("/editUserInfo")
    @ResponseBody
    public ResponseJson editUserInfo() throws AjaxOperationFailException {
        return userService.editUserInfo();
    }

}
